package com.example.yeujian5.yuejian5.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import com.example.yeujian5.yuejian5.Listenner.MasterListener;
import com.example.yeujian5.yuejian5.R;
import com.example.yeujian5.yuejian5.adapter.MasterAdapter;
import com.example.yeujian5.yuejian5.bean.MasterBean;
import com.example.yeujian5.yuejian5.bean.MasterVideoBean;
import com.example.yeujian5.yuejian5.bean.QuestionBean;
import com.example.yeujian5.yuejian5.model.MasterModel;

import java.util.List;

/**
 * Created by wangmengmeng on 2017/10/7.
 */

public class MasterFragment extends Fragment implements MasterListener {
        private RecyclerView recyclerView;
        List<MasterBean> list;

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                                 Bundle savedInstanceState)
        {
            View view=inflater.inflate(R.layout.fragment_master, container, false);
            initRecyclerView(view);
            MasterModel model=new MasterModel();
            model.getList("45","",this);
            return  view;
        }

    public  void initRecyclerView(View view){

        recyclerView= (RecyclerView) view.findViewById(R.id.master_Rec);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        recyclerView.setItemAnimator(new DefaultItemAnimator());
    }

    @Override
    public void onResponse(List<MasterBean> listBeen) {
        list=listBeen;
        recyclerView.setAdapter(new MasterAdapter(getActivity(),list));
    }

    @Override
    public void onFail(String msg) {
        Toast.makeText(getActivity(), ""+msg, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void onResponseVideo(List<MasterVideoBean> listBeen) {

    }

    @Override
    public void onResponseQuestion(List<QuestionBean> listbeen) {

    }


}
